package com.yonyou.struts2demo.form;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.ServletRequestAware;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author wwj
 * @Date 2021/12/10
 * @Description 获取表单数据第三种 接口注入 ServletRequestAware
 */
public class FormThirdAction extends ActionSupport implements ServletRequestAware {

    HttpServletRequest request;

    @Override
    public void setServletRequest(HttpServletRequest request) {
        this.request = request;
    }

    @Override
    public String execute() throws Exception {

        request.setAttribute("message", "通过 ServletRequestAware 接口实现了访问 Servlet API");
        return SUCCESS;
    }
}
